<html>
<head>
<title>BrowseWsdlService Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>BrowseWsdlService Test</h1>

<p>
small test using <a href="http://www.urdalen.no/wsdl2php/manual.php">http://www.urdalen.no/wsdl2php/manual.php</a>
<pre>
install tools:

wget 'http://downloads.sourceforge.net/project/wsdl2php/wsdl2php/wsdl2php-0.2.1-pear/wsdl2php-0.2.1-pear.tgz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fwsdl2php%2F&ts=1323178910&use_mirror=dfn' -O wsdl2php-0.2.1-pear.tgz
sudo apt-get install php-pear
sudo pear install wsdl2php-0.2.1-pear.tgz 

run:

wsdl2php 'http://soaponix.appspot.com/BrowseSoapServlet/nl/boektrust/btsoep/server/wsdl/jaxws/BrowseWsdlService.wsdl'
php hello.php 
</pre>
</p>

<hr/>

<?php
//FORM will POST or GET to this same page, so get all variables safely:
$minauteur=(isset($_REQUEST['minauteur'])?$_REQUEST['minauteur']:NULL);
$maxauteur=(isset($_REQUEST['maxauteur'])?$_REQUEST['maxauteur']:NULL);
$minisbn=(isset($_REQUEST['minisbn'])?$_REQUEST['minisbn']:NULL);
$maxisbn=(isset($_REQUEST['maxisbn'])?$_REQUEST['maxisbn']:NULL);
$mintitel=(isset($_REQUEST['mintitel'])?$_REQUEST['mintitel']:NULL);
$maxtitel=(isset($_REQUEST['maxtitel'])?$_REQUEST['maxtitel']:NULL);
$offset=(isset($_REQUEST['offset'])?$_REQUEST['offset']:NULL);
if (is_numeric($offset)) { $offset=intval($offset); } else { $offset=0; }
$limit=(isset($_REQUEST['limit'])?$_REQUEST['limit']:NULL);
if (is_numeric($limit)) { $limit=intval($limit); } else { $limit=10; }

//make a FORM to search from MIN to MAX (fields are ignored when not filled) with LIMIT and OFFSET
echo "
<p>
Zoek formulier voor een kunstmatige data set. Die data set bevat 'boeken' met een auteur, isbn en titel. 
En is gevuld met de reeks van (auteur1000, isbn1000, titel1000) tot en met (auteur1999, isbn1999, titel1999).
U kunt zoeken met een optionele onder (min) en boven grens (max).
Voor het geval er teveel resultaten terug komen is er een maximum aantal 'limit' en een paginering met 'offset' ingebouwd.
</p>
<p>
<form action='hello.php' method='post'>
<table border='1'>
<tr>
<th>auteur</th>
<th>isbn</th>
<th>titel</th>
</tr>
<tr>
<td><input type='text' name='minauteur' value='$minauteur' /></td>
<td><input type='text' name='minisbn' value='$minisbn' /></td>
<td><input type='text' name='mintitel' value='$mintitel' /></td>
</tr>
<tr>
<td><input type='text' name='maxauteur' value='$maxauteur' /></td>
<td><input type='text' name='maxisbn' value='$maxisbn' /></td>
<td><input type='text' name='maxtitel' value='$maxtitel' /></td>
</tr>
</table>
<table border='1'>
<tr>
<th>offset</th><th>limit</th>
</tr>
<tr>
<td><input type='text' name='offset' value='$offset' /></td>
<td><input type='text' name='limit' value='$limit' /></td>
</tr>
</table>
<input type='submit' value='Zoek'>
</form>
</p>
<p>
";

//load PHP file, generated by the wsdl2php tool:
require_once 'BrowseWsdlService.php';
$hello = new BrowseWsdlService();

//filter MIN value, if NULL then no MIN filter:
$from = new book(); //class book {  public $auteur; public $isbn; public $titel; }
$from->auteur=$minauteur;
$from->isbn=$minisbn;
$from->titel=$mintitel;
//var_export($from);
//MAX value filter:
$to = new book();
$to->auteur=$maxauteur;
$to->isbn=$maxisbn;
$to->titel=$maxtitel;
//make request object with FROM, TO, LIMIT and OFFSET:
$search = new searchBooks();
$search->arg0=$from;
$search->arg1=$to;
$search->arg2=$offset;
$search->arg3=$limit;
//send request to server and retrieve response:
$ret = $hello->searchBooks($search);
/*
echo "<pre>";
var_export($search);
echo "</pre>";
echo "<pre>";
var_export($ret);
echo "</pre>";
//print_r($ret);
//var_dump($ret);
//var_export($ret);
//print "so far so good";
//var_export($ret->return[0]);
*/

//print all items from response list:
echo "<table border='1'>
<tr>
<th>auteur</th>
<th>isbn</th>
<th>titel</th>
</tr>";
//NOTE: return amount of 1 book is not an array anymore!!! It will loop wrongly over the 3 items in the Book.
//bool is_array ( mixed $var )
if (is_object($ret->return)) {
echo "<tr><td>";
echo $ret->return->auteur;
echo "</td><td>";
echo $ret->return->isbn;
echo "</td><td>";
echo $ret->return->titel;
echo "</td></tr>";
} else {
foreach($ret->return as $key => $value){
echo "<tr>
<td>$value->auteur</td>
<td>$value->isbn</td>
<td>$value->titel</td>
</tr>";
}
}
echo "</table>";

?>
</p>


<!--
<h2>PHP Information</h2>
<p>
<?php phpinfo(); ?>
</p>
-->

</body>
</html>




